package webUtils;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.codec.binary.Base64;
import com.alibaba.fastjson.JSONObject;

/**
* @author 作者 linweiqiang
* @version 创建时间：2017年9月28日 上午11:34:42
* 类说明
*/
public class GetSign {
	
	public static Map<String , String> getSign(Map<String,String> parameters) throws UnsupportedEncodingException, Exception{
		String customerNo = parameters.remove("customerNo");
		String encryptBody = JSONObject.toJSONString(parameters);
//		System.out.println("encryptBody:" + encryptBody);
		byte[] RSAData = RSAUtils.encryptByPrivateKey(encryptBody.getBytes("UTF-8"), "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAOEyW5/xhKIoH0WIohSIkZkqfnLFWbExeR/6Ucu5CFI/Ouv0n41FK+E/POkBOZCsPcFo94BEr3TmWHf8XwAvMYm2whwDneA0X9tn0qnyTVwKsVUXVzhy6/wX6/w0wlnW+kWp4vAbLS9cQBRDe3fk7DsRnxVW9Y/kese2cTjN+hK1AgMBAAECgYA3tDAr4R8QyWHq3kBRWfLB81vx4dUs2nL+sPmYrf1b8t4NTaZF2I1hGzZi4HWvzps8A03tgY/xF6VckKWjMwlKc4cHdI37T/4z73CJyuqNlSfRTy0WcUs3G19jK3okXYMqJBWyg7oyNWj2Td0qqemoPDwsV5tI7YlryhzUFY52wQJBAPTFbylUm473LA/LurUaRGSyT8R7osnPCD9SmUttDXZypICb7IAVb+qR+PT1M2Nkmv3HywhFyqtHeFv4LolhWGUCQQDrhwryTG24ilaZkjbM0e8FVyWuWU8IrKKiuchP+YDf0ZZ3XsFiY6DQdZ/FSWnmSrbVyevcQ/euTnd0vZK78SQRAkB4xiZoXU/4Reuey6aPj6tpiDYlu9+B9j6aiBYNinyXElArCUSzmmBDfM07iPVXOJ/lUrzSkyVCSBySPK4xqS+lAkAntT/CM+J3r1MEVyNICsi6ZMPkjggGFVziBGJiIVV55pLwkxgVZ2iQXJRQJZ1mBwimKIHMQ+U5DN+U3fUkHHaRAkEAwghyJDXxxCaQvauYciPAApZ9TwucgSQFcx1xTpnipvB1nTUJvjTOZzHNwca5iWjaxUqsTfaBvqLVki8mk2byNw==");
		String encryptedData = Base64.encodeBase64String(RSAData);
//		System.out.println("encryptedData:"+encryptedData);
		
		Map<String, String> encryptMap = new HashMap<String, String>();
		encryptMap.put("encryptedData", encryptedData);
		encryptMap.put("customerNo", customerNo);
		return encryptMap;
	}
}
